$(function(){HowToSlideshow.init();window.setInterval("HowToSlideshow.cycle()",20000)});var HowToSlideshow={init:function(){$('.slideshow-btn').each(function(i){$(this).click(function(e){$('.guides-slideshow div.how-to').hide().eq(i).fadeIn('slow');HowToSlideshow.currentSlide=i;$(this).removeClass().addClass('slideshow-btn-active').siblings().removeClass().addClass('slideshow-btn')})});HowToSlideshow.cycle()},cycle:function(){if(HowToSlideshow.currentSlide>=4)HowToSlideshow.currentSlide=0;$('.slideshow-btn:eq('+HowToSlideshow.currentSlide+')').trigger('click')},currentSlide:0};$(document).ready(function(){var CommentaryHomeModel=function(){var nextOffset=5
function updateCommentForm(data){drawNewComment(data);CommentaryHomeModel.resetCommentForm()}
function sendAJAXComment(){var id=$('.submission .share-form .submit').attr('name').replace('ch_submit_id_','');var type_name=$('.submission .share-form .submit').attr('id').replace('ch_submit_type_','');var comment=encodeURIComponent($('.submission .share-form .text-area').val());var uri='';if(type_name=='CityGuide')uri='/index/cityguidecomment';if(type_name=='HowTo')uri='/howto/howtoguidecomment';if(type_name=='Article')uri='/article/articlecomment';$.ajax({type:"GET",url:uri,data:'ajax=1&item_id='+id+'&type_name='+type_name+'&comment='+comment,success:function(data){updateCommentForm(data)}})}
function drawNewComment(markup){$('.commentary-home .submission').after(markup);$('.commentary-home-no-comment').remove()}
function drawMoreComments(markup){$('.commentary-home .comment-last .comment').attr('style','border-bottom:2px dashed #D7D7D7;padding:10px 0;');$('.commentary-home .comment-last').replaceWith($('.commentary-home .comment-last .comment'));$('.commentary-home').append(markup);CommentaryHomeModel.setUsUpTheViewMoreBomb()};return {submitComment:function(){this.disableCommentForm();sendAJAXComment()},disableCommentForm:function(){$('.submission .share-form .text-area').attr('disabled',true);$('.submission .share-form .submit').unbind('click');$('.submission .share-form .submit').attr('disabled',true);$('.submission .share-form .submit').fadeTo('slow',0.33)},resetCommentForm:function(){$('.submission .share-form .submit').unbind('click');$('.submission .share-form .submit').click(function(){if(jQuery.trim($('.submission .share-form .text-area').val()).length>0)CommentaryHomeModel.submitComment()});$('.submission .share-form .text-area').val('');$('.submission .share-form .text-area').attr('disabled',false);$('.submission .share-form .submit').attr('disabled',false);$('.submission .share-form .submit').fadeTo('fast',1);registerAbuseLinks();registerLiking();registerBadging()},setUsUpTheViewMoreBomb:function(){$('.comment-last .comment .view-more').click(function(){var type_name=$('.comment-last .comment .view-more').attr('id').replace('ch_submit_type_','');var item_id=$('.comment-last .comment .view-more').attr('name').replace('ch_submit_id_','');$('.comment-last .comment .view-more').unbind('click');$('.comment-last .comment .view-more').remove();var item_id_string='';var uri='';if(type_name=='CityGuide')uri='/index/getmorecityguidecomments';if(type_name=='HowTo'){uri='/howto/getmorehowtoguidecomments';item_id_string='&item_id='+item_id};if(type_name=='Article'){uri='/article/getmorearticlecomments';item_id_string='&item_id='+item_id};$.ajax({type:"GET",url:uri,data:'ajax=1&offset='+nextOffset+'&limit=5'+item_id_string,success:function(data){nextOffset+=5;drawMoreComments(data);registerAbuseLinks();registerLiking();registerBadging()}})})}}}();CommentaryHomeModel.resetCommentForm();CommentaryHomeModel.setUsUpTheViewMoreBomb()});$(function(){$('.google-map .nav a').click(function(){if(!$(this).hasClass('active')){$('#mapiframe').attr("src","/map/search/category/"+$(this).attr("class"));$('.google-map .nav a.active').attr("class",$('.google-map .nav a.active').attr("class").split(' ')[0]);$('.'+$(this).attr("class")).attr("class",$(this).attr("class")+' active')}})})